<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<%@ page import="org.apache.struts2.ServletActionContext" %>
<%@ page import="org.controller.registration.*" %>
<%@ page import="java.util.ArrayList" %>
<head>


<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title>BMET</title>
 <link rel="stylesheet" href="/BMREG_WEB/resources/css/style.css" />	
 <script type="text/javascript" src="/BMREG_WEB/resources/js/lib/prototype-1.6.0.2.js"></script>	
  <script type="text/javascript" src="/BMREG_WEB/resources/js/lib/jquery-1.6.4.min.js"></script> 
<script type="text/javascript" src="/BMREG_WEB/resources/js/util/util.js"></script>
<script type="text/javascript" src="/BMREG_WEB/resources/js/util/numeric.js"></script>
 
 <link type="text/css" rel="Stylesheet" href="/BMREG_WEB/resources/js/lib/jquery.validity.1.2.0/jquery.validity.css" />
        <script type="text/javascript" src="/BMREG_WEB/resources/js/lib/jquery.validity.1.2.0/jQuery.validity.js"></script>
 
  <script type="text/javascript" src="/BMREG_WEB/resources/js/address.js"></script>
  
  <script type="text/javascript">

var ajax_load="<br/><center><img src='/BMREG_WEB/resources/images/ajax-loader1.gif' border='0' /></center>";

function addNewType()
{
 var regIdSuffix=document.getElementById("regIdSuffix").value;
 var typeName=document.getElementById("typeName").value;
 var typeDesc=document.getElementById("typeDesc").value;
 var isActive=$("input[name=isActive]:checked").val()
 
 
 
 var loadUrl="addNewRegType.action?regIdSuffix="+regIdSuffix+"&typeName="+encodeURIComponent(typeName)+"&typeDesc="+encodeURIComponent(typeDesc)+"&isActive="+isActive;
			jQuery("#msgDiv")  
				.html(ajax_load)  
				.load(loadUrl, {},function(responseText){  
				    alert(responseText);
					jQuery("#msgDiv").html(responseText);
					document.getElementById("regIdSuffix").value="";
					document.getElementById("typeName").value="";
					document.getElementById("typeDesc").value="";
					refreshRegTypeListDiv();
									   
				});
 
 
}


function updateRegType(regTypeId,index){

 var regIdSuffix=document.getElementById("regIdSuffix"+index).value;
 var typeName=document.getElementById("typeName"+index).value;
 var typeDesc=document.getElementById("typeDesc"+index).value;
 var isActive=document.getElementById("isActive"+index).value;
 
 var loadUrl="updateRegType.action?typeId="+regTypeId+"&regIdSuffix="+regIdSuffix+"&typeName="+encodeURIComponent(typeName)+"&typeDesc="+encodeURIComponent(typeDesc)+"&isActive="+isActive;
			jQuery("#msgDiv")  
				.html(ajax_load)  
				.load(loadUrl, {},function(responseText){  
				    alert(responseText);
					jQuery("#msgDiv").html(responseText);
									   
				});

}
function deleteRegType(regTypeId){

var r=confirm("Are you sure you want to delete?");
if (r==true)
  {
 var loadUrl="deleteRegType.action?typeId="+regTypeId;
			jQuery("#msgDiv")  
				.html(ajax_load)  
				.load(loadUrl, {},function(responseText){
				    alert(responseText);  
					jQuery("#msgDiv").html(responseText);
					refreshRegTypeListDiv();			   
				});
				
  				

  }
  

}

function refreshRegTypeListDiv()
{
 var loadUrl="fetchRegTypeList.action";
			jQuery("#regTypeListDiv")  
				.html(ajax_load)  
				.load(loadUrl, {},function(responseText){  
					jQuery("#degreeListDiv").html(responseText);				   
				});
}
function setVisibilityValue(elementId)
{
 if(document.getElementById(elementId).checked==true)
  document.getElementById(elementId).value=1;
 else
 document.getElementById(elementId).value=0;
 
}


</script>
</head>
<body style="margin: 0px;">

<div style="width: 100%;height: 100px;border-bottom: 1px solid #006219;">
<center>
<div style="width: 1000px;height: 100px;border-right: 1px solid #006219;border-left: 1px solid #006219;">
	<div style="float: left; margin-top: 20px;width: 100px;">
	 <img src="/BMREG_WEB/resources/images/bagladesh_logo.gif" width="60" height="60" />
	</div>
	<div style="float: left;margin-left: 30px;color: black;margin-top: 15px;text-align: left;">
	 	<div style="font-size: 27px;font-weight: bold;">Bureau of Manpower, Employment & Training (BMET)</div>
	</div>
</div>
</center>
</div>
<center>
<br/>
<div class="box" style="margin-top: 20px;width: 900px;text-align: center;">
    <h3>Registration Type Management</h3>
    <div style="padding-bottom: 30px;">
     <div id="regTypeListDiv">
     <table width="98%" align="center" border="0" cellpadding="2" cellspacing="0" style="border: 1px solid grey;">     
     <tr bgcolor="#F1F1F1">
     
        <td width="10%" align="center"  height="25">SL</td>
      	<td width="10%" align="left"    height="25">Reg Suffix</td>
      	<td width="30%" align="left"  height="25">Type Name</td>
      	<td width="30%" align="left"  height="25">Type Desc</td>
      	<td width="10%" align="center"  height="25">Is Active</td>
      	<td width="10%" align="center"  height="25">Edit/Delete</td>
      </tr>            
      <s:iterator value="regTypeList" id="type" status="indx">
        <tr>
        <td align="center"  height="25">
        <s:property value="%{#indx.count}" />.
        </td>
      	<td align="left" style="padding-left: 10px;" height="25">      		
      		<input type="text" name="rList[<s:property value="%{#indx.index}" />].regIdSuffix" value="<s:property value="regIdSuffix" />" id="regIdSuffix<s:property value='%{#indx.count}' />"  style="border: 1px solid grey;width: 40px;" />
      	</td>
      	<td align="center" style="" height="25">
      		<input type="text" name="rList[<s:property value="%{#indx.index}" />].typeName" value="<s:property value="typeName" />" id="typeName<s:property value='%{#indx.count}' />" style="border: 1px solid grey;width: 180px;text-align: left;"/>
      	</td>
      	<td align="left" style="padding-left: 10px;" height="25">      		
      		<input type="text" name="rList[<s:property value="%{#indx.index}" />].typeDesc" value="<s:property value="typeDesc" />" id="typeDesc<s:property value='%{#indx.count}' />"  style="border: 1px solid grey;width: 180px;text-align: left;" />
      	</td>
      	<td align="center" height="25">      	 
	      	<s:if test="#type.isActive==1">
			  <input type="checkbox" name="rList[<s:property value="%{#indx.index}" />].isActive" checked="checked" id="isActive<s:property value="%{#indx.count}" />" value="1" onclick="setVisibilityValue(this.id)" />
			</s:if>
			<s:elseif test="#type.isActive==0">
			  <input type="checkbox" name="rList[<s:property value="%{#indx.index}" />].isActive" id="isActive<s:property value="%{#indx.count}" />" value="0"  onclick="setVisibilityValue(this.id)" />
			</s:elseif>
		</td>
      	<td align="center"  height="25">
      	<a href="#" onclick='updateRegType(<s:property value="typeId" />,<s:property value="%{#indx.count}" />)'  style="text-decoration: none;">
	      	<img src='/BMREG_WEB/resources/images/edit.png' border='0' width="20" height="20"/>
      	</a>
      	&nbsp;&nbsp;&nbsp;
      	<a href="#" onclick='deleteRegType(<s:property value="typeId" />)'  style="text-decoration: none;">
      	 <img src='/BMREG_WEB/resources/images/delete.png' border='0'  width="20" height="20"/>
      	 </a>
      	</td>
        </tr> 
      </s:iterator>
      
      
    </table>
     
     </div>
   
    <br/>
    <div style="float: left;font-size: 18px;font-weight: bold;color: blue;padding-left: 10px;">New Reg. Type Entry</div>
    <br style="clear: both;"/>
    <table width="98%" align="center" border="0" cellpadding="2" cellspacing="0" style="border: 1px solid grey;margin-top: 20px;">
    
     <tr>
	    <td height="40px;">Reg. Suffix: <input type="text" style="border: 1px solid grey;width:40px;"  id="regIdSuffix"/></td>
	    <td height="40px;">Type Name: <input type="text" style="border: 1px solid grey;width:180px;"  id="typeName"/></td>
	    <td height="40px;">Type Desc: <input type="text" style="border: 1px solid grey;width:180px;"  id="typeDesc"/></td>
	    <td height="40px;">Is Active? 
	    <input type="radio" value="1" id="isActiveYes" name="isActive" /> Yes
	    <input type="radio" value="0" checked="checked" id="isActiveNo" name="isActive" /> No
	    </td>    
    </tr>
    
    </table>    
<p style="padding-top: 20px;">     
<input type="button" name="save" value="Add New Type" style="width: 200px;height: 35px;"  onclick="addNewType()"/>
</p>
</div>
    
    <p style="padding-bottom: 20px;">
    <a href="systemAdminHome.action">Go Home</a>
    </p>

</div>
<p id="msgDiv"></p>
</center>

</body>

</html>